# -*- makefile -*-

# Utilities.
bin_UTILITIES = grub-mkimage

# For grub-mkimage.
grub_mkimage_SOURCES = gnulib/progname.c util/efi/grub-mkimage.c \
	util/misc.c util/resolve.c util/obj.c kern/list.c
util/i386/efi/grub-mkimage.c_DEPENDENCIES = Makefile

# Scripts.
sbin_SCRIPTS = grub-install

# For grub-install.
grub_install_SOURCES = util/i386/efi/grub-install.in

# Modules.
pkglib_MODULES = kernel.mod chain.mod appleldr.mod \
	linux.mod halt.mod  \
	datetime.mod loadbios.mod \
	fixvideo.mod mmap.mod acpi.mod

# For kernel.mod.
kernel_mod_SOURCES = kern/$(target_cpu)/efi/startup.S kern/main.c kern/device.c \
	kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
	kern/misc.c kern/mm.c kern/term.c \
	kern/rescue_parser.c kern/rescue_reader.c \
	kern/i386/efi/init.c kern/parser.c kern/partition.c \
	kern/env.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c \
	term/efi/console.c disk/efi/efidisk.c \
	kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
	kern/i386/tsc.c kern/i386/pit.c \
	kern/generic/rtc_get_time_ms.c \
	kern/generic/millisleep.c
ifeq ($(target_cpu),x86_64)
kernel_mod_SOURCES += kern/x86_64/efi/callwrap.S
endif
kernel_mod_CFLAGS = $(COMMON_CFLAGS)
kernel_mod_ASFLAGS = $(COMMON_ASFLAGS)
kernel_mod_LDFLAGS += $(COMMON_LDFLAGS)

# For acpi.mod.
acpi_mod_SOURCES = commands/acpi.c commands/efi/acpi.c
acpi_mod_CFLAGS = $(COMMON_CFLAGS)
acpi_mod_LDFLAGS = $(COMMON_LDFLAGS)

# For mmap.mod.
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c \
		   mmap/efi/mmap.c
mmap_mod_CFLAGS = $(COMMON_CFLAGS)
mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)

# For chain.mod.
chain_mod_SOURCES = loader/efi/chainloader.c
chain_mod_CFLAGS = $(COMMON_CFLAGS)
chain_mod_LDFLAGS = $(COMMON_LDFLAGS)

# For appleldr.mod.
appleldr_mod_SOURCES = loader/efi/appleloader.c
appleldr_mod_CFLAGS = $(COMMON_CFLAGS)
appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS)

# For linux.mod.
ifeq ($(target_cpu), x86_64)
linux_mod_SOURCES = loader/i386/efi/linux.c loader/i386/linux_trampoline.S
linux_mod_CFLAGS = $(COMMON_CFLAGS)
linux_mod_ASFLAGS = $(COMMON_ASFLAGS)
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
else
linux_mod_SOURCES = loader/i386/efi/linux.c
linux_mod_CFLAGS = $(COMMON_CFLAGS)
linux_mod_ASFLAGS = $(COMMON_ASFLAGS)
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
endif

# For halt.mod.
halt_mod_SOURCES = commands/halt.c
halt_mod_CFLAGS = $(COMMON_CFLAGS)
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)

# For datetime.mod
datetime_mod_SOURCES = lib/efi/datetime.c
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)

# For loadbios.mod
loadbios_mod_SOURCES = commands/efi/loadbios.c
loadbios_mod_CFLAGS = $(COMMON_CFLAGS)
loadbios_mod_LDFLAGS = $(COMMON_LDFLAGS)

# For fixvideo.mod
fixvideo_mod_SOURCES = commands/efi/fixvideo.c
fixvideo_mod_CFLAGS = $(COMMON_CFLAGS)
fixvideo_mod_LDFLAGS = $(COMMON_LDFLAGS)

#pkglib_MODULES += efi_uga.mod
efi_uga_mod_SOURCES = video/efi_uga.c
efi_uga_mod_CFLAGS = $(COMMON_CFLAGS)
efi_uga_mod_LDFLAGS = $(COMMON_LDFLAGS)

#pkglib_MODULES += efi_gop.mod
efi_gop_mod_SOURCES = video/efi_gop.c
efi_gop_mod_CFLAGS = $(COMMON_CFLAGS)
efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS)

pkglib_MODULES += efi_fb.mod
efi_fb_mod_SOURCES = video/efi/efi_fb.c
efi_fb_mod_CFLAGS = $(COMMON_CFLAGS)
efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS)

pkglib_MODULES += xnu.mod
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c \
	loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)

pkglib_MODULES += efivars.mod
efivars_mod_SOURCES = commands/efi/efivars.c
efivars_mod_CFLAGS = $(COMMON_CFLAGS)
efivars_mod_ASFLAGS = $(COMMON_ASFLAGS)

pkglib_MODULES += netfs.mod
netfs_mod_SOURCES = fs/efi/netfs.c
netfs_mod_CFLAGS = $(COMMON_CFLAGS)
netfs_mod_ASFLAGS = $(COMMON_ASFLAGS)

include $(srcdir)/conf/i386.mk
include $(srcdir)/conf/common.mk
